const http = require("http");

const fs = require("fs");

const path = require("path");

const url = require("url");



// 创建服务

http.createServer((req,res)=>{
    let { pathname } = url.parse(req.url,true); 

    // console.log(url.parse(req.url,true))

    pathname = pathname === "/"? "/index.html" : pathname;

    if(path.extname(pathname) && path.extname(pathname) !== "/.ico" ){
        res.end(fs.readFileSync(path.join("./public",pathname),"utf-8"));
    }else if(pathname === "/login"){
        //.....
    }else if(pathname === "/registry"){
        //.....
    }

}).listen(9000,()=>{
    console.log("service is running at http://localhost:9000")    
})